<%@ Control Language="C#" ClassName="StateFlow_Groups" Inherits="Dimok.Web.UI.TableControl" %>
<%@ Register Namespace="Dimok.Web.UI"  Assembly="Dimok.Web.UI" TagPrefix="OR"  %>
<%@ Register Namespace="Data.DataSources" Assembly="App_Code" TagPrefix="DS"  %>

<script runat="server">
	public int StateFromID {
		get { return ds.StateFromID; }
		set { ds.StateFromID = value; }
	}
	public int StateToID {
		get { return ds.StateToID; }
		set { ds.StateToID = value; }
	}
	protected void OnRowCreated(object sender, GridViewRowEventArgs e) {
		if(e.Row.RowType != DataControlRowType.Footer )return;
		TextBox txt = (TextBox)e.Row.Cells[0].FindControl("StateFromID");
		txt.Text = ds.StateFromID + "";
		txt = (TextBox)e.Row.Cells[0].FindControl("StateToID");
		txt.Text = ds.StateToID + "";
	}
</script>

<asp:UpdatePanel ID="pnl" UpdateMode="Always" runat="server">
	<ContentTemplate>
		<OR:GridViewEx ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds"
			ShowFooter="True" AllowSorting="True" BackColor="Window" CellPadding="0" EnableTheming="True"
			Font-Names="verdana" EnableViewState="False" DataKeyNames="StateFromID,StateToID,GroupName" DebugMode="true"
			ViewNameUpdate="t_StateFlow_Groups" ViewNameInsert="t_StateFlow_Groups" OnRowCreated="OnRowCreated"
			>
			<Columns>

				<asp:TemplateField HeaderText="" SortExpression="StateFromID">
					<ItemTemplate><asp:Label Text='<%#Eval("StateFromID") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate><asp:Label Text='<%#Eval("StateFromID") %>' runat="server" /></EditItemTemplate>
					<FooterTemplate>
						<asp:TextBox id="StateFromID" runat="server" />
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="" SortExpression="StateToID">
					<ItemTemplate><asp:Label Text='<%#Eval("StateToID") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate><asp:Label Text='<%#Eval("StateToID") %>' runat="server" /></EditItemTemplate>
					<FooterTemplate>
						<asp:TextBox id="StateToID" runat="server" />
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="Group" SortExpression="Name">
					<ItemTemplate><asp:Label Text='<%#Eval("GroupName") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate>
						<asp:DropDownList ID="selGroupName" DataSourceID="dsGroups" DataTextField="Name" DataValueField="Name" runat="server"
								 SelectedValue='<%# Bind("Name") %>'></asp:DropDownList>
					</EditItemTemplate>
					<FooterTemplate>
						<asp:DropDownList ID="GroupName" DataSourceID="dsGroups" DataTextField="Name" DataValueField="Name" runat="server"></asp:DropDownList>
					</FooterTemplate>
				</asp:TemplateField>
			</Columns>
		</OR:GridViewEx>
	</ContentTemplate>
</asp:UpdatePanel>

<DS:StateFlows_GroupsDataSource ID="ds" runat="server" />
<DS:GroupsDataSource ID="dsGroups" runat="server" />
